home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Programming / MPW Interfaces & Libraries 3.1 / PInterfaces / MIDI.p < prev    next >
Encoding:
Text File  |  1989-10-13  |  9.9 KB  |  280 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Monday, September 18, 1989 at 8:03 PM
  3.     MIDI.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.     
  7.        
  8.         Author: John Worthington, Don Marsh, Mark Lentczner
  9.         Copyright © 1988, Apple Computer, Inc.
  10.         All Rights Reserved
  11.      
  12. }
  13.  
  14.  
  15. {$IFC UNDEFINED UsingIncludes}
  16. {$SETC UsingIncludes := 0}
  17. {$ENDC}
  18.  
  19. {$IFC NOT UsingIncludes}
  20.     UNIT MIDI;
  21.     INTERFACE
  22. {$ENDC}
  23.  
  24. {$IFC UNDEFINED UsingMIDI}
  25. {$SETC UsingMIDI := 1}
  26.  
  27. {$I+}
  28. {$SETC MIDIIncludes := UsingIncludes}
  29. {$SETC UsingIncludes := 1}
  30. {$IFC UNDEFINED UsingTypes}
  31. {$I $$Shell(PInterfaces)Types.p}
  32. {$ENDC}
  33. {$SETC UsingIncludes := MIDIIncludes}
  34.  
  35. CONST
  36. midiToolNum = 4;                {tool number of MIDI Manager for SndDispVersion call}
  37. midiMaxNameLen = 31;            {maximum number of characters in port and client names}
  38.  
  39. { Time formats }
  40.  
  41. midiFormatMSec = 0;             {milliseconds}
  42. midiFormatBeats = 1;            {beats}
  43. midiFormat24fpsBit = 2;         {24 frames/sec.}
  44. midiFormat25fpsBit = 3;         {25 frames/sec.}
  45. midiFormat30fpsDBit = 4;        {30 frames/sec. drop-frame}
  46. midiFormat30fpsBit = 5;         {30 frames/sec.}
  47. midiFormat24fpsQF = 6;          {24 frames/sec. longInt format }
  48. midiFormat25fpsQF = 7;          {25 frames/sec. longInt format }
  49. midiFormat30fpsDQF = 8;         {30 frames/sec. drop-frame longInt format }
  50. midiFormat30fpsQF = 9;          {30 frames/sec. longInt format }
  51. midiInternalSync = 0;           {internal sync}
  52. midiExternalSync = 1;           {external sync}
  53.  
  54. {  Port types }
  55.  
  56. midiPortTypeTime = 0;           {time port}
  57. midiPortTypeInput = 1;          {input port}
  58. midiPortTypeOutput = 2;         {output port}
  59. midiPortTypeTimeInv = 3;        {invisible time port}
  60.  
  61. { OffsetTimes  }
  62.  
  63. midiGetEverything = $7FFFFFFF;  {get all packets, regardless of time stamps}
  64. midiGetNothing = $80000000;     {get no packets, regardless of time stamps}
  65. midiGetCurrent = $00000000;     {get current packets only}
  66.  
  67. {     MIDI data and messages are passed in MIDIPacket records (see below).
  68.     The first byte of every MIDIPacket contains a set of flags
  69.    
  70.     bits 0-1    00 = new MIDIPacket, not continued
  71.                      01 = begining of continued MIDIPacket
  72.                      10 = end of continued MIDIPacket
  73.                     11 = continuation
  74.     bits 2-3     reserved
  75.   
  76.     bits 4-6      000 = packet contains MIDI data
  77.    
  78.                      001 = packet contains MIDI Manager message
  79.    
  80.     bit 7              0 = MIDIPacket has valid stamp
  81.                         1 = stamp with current clock }
  82.  
  83. midiContMask = $03;
  84. midiNoCont = $00;
  85. midiStartCont = $01;
  86. midiMidCont = $03;
  87. midiEndCont = $02;
  88. midiTypeMask = $70;
  89. midiMsgType = $00;
  90. midiMgrType = $10;
  91. midiTimeStampMask = $80;
  92. midiTimeStampCurrent = $80;
  93. midiTimeStampValid = $00;
  94.  
  95. {     MIDI Manager MIDIPacket command words (the first word in the data field
  96.     for midiMgrType messages) }
  97.  
  98. midiOverflowErr = $0001;
  99. midiSCCErr = $0002;
  100. midiPacketErr = $0003;
  101. midiMaxErr = $00FF;             {all command words less than this value  are error indicators}
  102.  
  103. { Valid results to be returned by readHooks  }
  104.  
  105. midiKeepPacket = 0;
  106. midiMorePacket = 1;
  107. midiNoMorePacket = 2;
  108.  
  109. {  Errors: }
  110.  
  111. midiNoClientErr = -250;         {no client with that ID found}
  112. midiNoPortErr = -251;           {no port with that ID found}
  113. midiTooManyPortsErr = -252;     {too many ports already installed in the system}
  114. midiTooManyConsErr = -253;      {too many connections made}
  115. midiVConnectErr = -254;         {pending virtual connection created}
  116. midiVConnectMade = -255;        {pending virtual connection resolved}
  117. midiVConnectRmvd = -256;        {pending virtual connection removed}
  118. midiNoConErr = -257;            {no connection exists between specified ports}
  119. midiWriteErr = -258;            {MIDIWritePacket couldn't write to all connected ports}
  120. midiNameLenErr = -259;          {name supplied is longer than 31 characters}
  121. midiDupIDErr = -260;            {duplicate client ID}
  122. midiInvalidCmdErr = -261;       {command not supported for port type}
  123.  
  124. {      Driver calls: }
  125.  
  126. midiOpenDriver = 1;
  127. midiCloseDriver = 2;
  128.  
  129.  
  130. TYPE
  131.  
  132. MIDIPacketPtr = ^MIDIPacket;
  133. MIDIPacket = PACKED RECORD
  134.     flags: Byte;
  135.     len: Byte;
  136.     tStamp: LONGINT;
  137.     data: PACKED ARRAY [0..248] OF Byte;
  138.     END;
  139.  
  140. MIDIClkInfo = RECORD
  141.     sync: INTEGER;              {synchronization external/internal}
  142.     curTime: LONGINT;           {current value of port's clock}
  143.     format: INTEGER;            {time code format}
  144.     END;
  145.  
  146. MIDIIDRec = RECORD
  147.     clientID: OSType;
  148.     portID: OSType;
  149.     END;
  150.  
  151. MIDIPortInfoPtr = ^MIDIPortInfo;
  152. MIDIPortInfoHdl = ^MIDIPortInfoPtr;
  153. MIDIPortInfo = RECORD
  154.     portType: INTEGER;          {type of port}
  155.     timeBase: MIDIIDRec;        {MIDIIDRec for time base}
  156.     numConnects: INTEGER;       {number of connections}
  157.     cList: ARRAY [1..100] OF MIDIIDRec;
  158.     END;
  159.  
  160. MIDIPortParamsPtr = ^MIDIPortParams;
  161. MIDIPortParams = RECORD
  162.     portID: OSType;             {ID of port, unique within client}
  163.     portType: INTEGER;          {Type of port - input, output, time, etc.}
  164.     timeBase: INTEGER;          {refnum of time base, 0 if none}
  165.     offsetTime: LONGINT;        {offset for current time stamps}
  166.     readHook: Ptr;              {routine to call when input data is valid}
  167.     refCon: LONGINT;            {refcon for port (for client use)}
  168.     initClock: MIDIClkInfo;     {initial settings for a time base}
  169.     name: Str255;               {name of the port, This is a real live string, not a ptr.}
  170.     END;
  171.  
  172. MIDIIDListPtr = ^MIDIIDList;
  173. MIDIIDListHdl = ^MIDIIDListPtr;
  174. MIDIIDList = RECORD
  175.     numIDs: INTEGER;
  176.     list: ARRAY [1..100] OF OSType;
  177.     END;
  178.  
  179.  
  180.  
  181.  
  182.      Prototype Declarations for readHook and timeProc
  183.      
  184.      FUNCTION myReadHook(myPacket: MIDIPacketPtr; myRefCon: LONGINT) : INTEGER;
  185.      PROCEDURE myTimeProc(curTime: LONGINT; myRefCon: LONGINT);
  186. }
  187.  
  188. FUNCTION SndDispVersion(toolnum: INTEGER): LONGINT;
  189. FUNCTION MIDISignIn(clientID: OSType;refCon: LONGINT;icon: Handle;name: Str255): OSErr;
  190.     INLINE $203C,$0004,midiToolNum,$A800;
  191. PROCEDURE MIDISignOut(clientID: OSType);
  192.     INLINE $203C,$0008,midiToolNum,$A800;
  193. FUNCTION MIDIGetClients: MIDIIDListHdl;
  194.     INLINE $203C,$000C,midiToolNum,$A800;
  195. PROCEDURE MIDIGetClientName(clientID: OSType;name: Str255);
  196.     INLINE $203C,$0010,midiToolNum,$A800;
  197. PROCEDURE MIDISetClientName(clientID: OSType;name: Str255);
  198.     INLINE $203C,$0014,midiToolNum,$A800;
  199. FUNCTION MIDIGetPorts(clientID: OSType): MIDIIDListHdl;
  200.     INLINE $203C,$0018,midiToolNum,$A800;
  201. FUNCTION MIDIAddPort(clientID: OSType;BufSize: INTEGER;VAR refnum: INTEGER;
  202.     init: MIDIPortParamsPtr): OSErr;
  203.     INLINE $203C,$001C,midiToolNum,$A800;
  204. FUNCTION MIDIGetPortInfo(clientID: OSType;portID: OSType): MIDIPortInfoHdl;
  205.     INLINE $203C,$0020,midiToolNum,$A800;
  206. FUNCTION MIDIConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  207.     dstPortID: OSType): OSErr;
  208.     INLINE $203C,$0024,midiToolNum,$A800;
  209. FUNCTION MIDIUnConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  210.     dstPortID: OSType): OSErr;
  211.     INLINE $203C,$0028,midiToolNum,$A800;
  212. FUNCTION MIDIConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  213.     dstPortID: OSType): OSErr;
  214.     INLINE $203C,$002C,midiToolNum,$A800;
  215. FUNCTION MIDIUnConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  216.     dstPortID: OSType): OSErr;
  217.     INLINE $203C,$0030,midiToolNum,$A800;
  218. PROCEDURE MIDIFlush(refnum: INTEGER);
  219.     INLINE $203C,$0034,midiToolNum,$A800;
  220. FUNCTION MIDIGetReadHook(refnum: INTEGER): ProcPtr;
  221.     INLINE $203C,$0038,midiToolNum,$A800;
  222. PROCEDURE MIDISetReadHook(refnum: INTEGER;hook: ProcPtr);
  223.     INLINE $203C,$003C,midiToolNum,$A800;
  224. PROCEDURE MIDIGetPortName(clientID: OSType;portID: OSType;name: Str255);
  225.     INLINE $203C,$0040,midiToolNum,$A800;
  226. PROCEDURE MIDISetPortName(clientID: OSType;portID: OSType;name: Str255);
  227.     INLINE $203C,$0044,midiToolNum,$A800;
  228. PROCEDURE MIDIWakeUp(refnum: INTEGER;time: LONGINT;period: LONGINT;timeProc: ProcPtr);
  229.     INLINE $203C,$0048,midiToolNum,$A800;
  230. PROCEDURE MIDIRemovePort(refnum: INTEGER);
  231.     INLINE $203C,$004C,midiToolNum,$A800;
  232. FUNCTION MIDIGetSync(refnum: INTEGER): INTEGER;
  233.     INLINE $203C,$0050,midiToolNum,$A800;
  234. PROCEDURE MIDISetSync(refnum: INTEGER;sync: INTEGER);
  235.     INLINE $203C,$0054,midiToolNum,$A800;
  236. FUNCTION MIDIGetCurTime(refnum: INTEGER): LONGINT;
  237.     INLINE $203C,$0058,midiToolNum,$A800;
  238. PROCEDURE MIDISetCurTime(refnum: INTEGER;time: LONGINT);
  239.     INLINE $203C,$005C,midiToolNum,$A800;
  240. PROCEDURE MIDIStartTime(refnum: INTEGER);
  241.     INLINE $203C,$0060,midiToolNum,$A800;
  242. PROCEDURE MIDIStopTime(refnum: INTEGER);
  243.     INLINE $203C,$0064,midiToolNum,$A800;
  244. PROCEDURE MIDIPoll(refnum: INTEGER;offsetTime: LONGINT);
  245.     INLINE $203C,$0068,midiToolNum,$A800;
  246. FUNCTION MIDIWritePacket(refnum: INTEGER;packet: MIDIPacketPtr): OSErr;
  247.     INLINE $203C,$006C,midiToolNum,$A800;
  248. FUNCTION MIDIWorldChanged(clientID: OSType): BOOLEAN;
  249.     INLINE $203C,$0070,midiToolNum,$A800;
  250. FUNCTION MIDIGetOffsetTime(refnum: INTEGER): LONGINT;
  251.     INLINE $203C,$0074,midiToolNum,$A800;
  252. PROCEDURE MIDISetOffsetTime(refnum: INTEGER;offsetTime: LONGINT);
  253.     INLINE $203C,$0078,midiToolNum,$A800;
  254. FUNCTION MIDIConvertTime(srcformat: INTEGER;dstformat: INTEGER;time: LONGINT): LONGINT;
  255.     INLINE $203C,$007C,midiToolNum,$A800;
  256. FUNCTION MIDIGetRefCon(refnum: INTEGER): LONGINT;
  257.     INLINE $203C,$0080,midiToolNum,$A800;
  258. PROCEDURE MIDISetRefCon(refnum: INTEGER;refCon: LONGINT);
  259.     INLINE $203C,$0084,midiToolNum,$A800;
  260. FUNCTION MIDIGetClRefCon(clientID: OSType): LONGINT;
  261.     INLINE $203C,$0088,midiToolNum,$A800;
  262. PROCEDURE MIDISetClRefCon(clientID: OSType;refCon: LONGINT);
  263.     INLINE $203C,$008C,midiToolNum,$A800;
  264. FUNCTION MIDIGetTCFormat(refnum: INTEGER): INTEGER;
  265.     INLINE $203C,$0090,midiToolNum,$A800;
  266. PROCEDURE MIDISetTCFormat(refnum: INTEGER;format: INTEGER);
  267.     INLINE $203C,$0094,midiToolNum,$A800;
  268. PROCEDURE MIDISetRunRate(refnum: INTEGER;rate: INTEGER;time: LONGINT);
  269.     INLINE $203C,$0098,midiToolNum,$A800;
  270. FUNCTION MIDIGetClientIcon(clientID: OSType): Handle;
  271.     INLINE $203C,$009C,midiToolNum,$A800;
  272.  
  273. {$ENDC}    { UsingMIDI }
  274.  
  275. {$IFC NOT UsingIncludes}
  276.     END.
  277. {$ENDC}
  278.  
  279.